﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using fmtx.Utility;

namespace website.Areas.Tool.Controllers
{
    public class CollectController : BaseController
    {
        //
        // GET: /Tool/Collect/

        public ActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 文章收集入口
        /// </summary>
        /// <param name="txtbody"></param>
        /// <returns></returns>
        [ValidateInput(false)]
        public ActionResult Article(string[] txtbody)
        {
            if (userInfo.Uid == 0)
            {
                TempData["collecttxt_txtbody"] = txtbody;
                var url = Request.RawUrl;
                return Redirect("~/login/?callback=" + url);
            }
            if (txtbody == null)
            {
                txtbody = TempData["collecttxt_txtbody"] as string[];
            }

            StringBuilder text = new StringBuilder();
            foreach (var item in txtbody)
            {
                text.Append("<p>");
                text.Append(item);
                text.Append("</p>");
            }
            TempData["collecttxt"] = text.ToString();
            return Redirect("/Write/Article/Edit");
        }

    }
}
